import http from '@/utils/http';
import type { _AxiosRequestConfig } from '@/utils/http/types';

const baseUrl = '/im/topic/user';

// 群聊列表
export const ApiChatList = () => http.get<any>('/im/chat-list');

// 创建
export const ApiChatAdd = (data: any, options?: _AxiosRequestConfig) => http.post<any>('/im/topic/create', data, options);

// 归档
export const ApiChatReturn = (topicId: number, options?: _AxiosRequestConfig) => http.put<any>(`/im/topic/archive/${topicId}`, options);

// 删除
export const ApiChatDelete = (topicId: number, options?: _AxiosRequestConfig) => http.delete<any>(`/im/topic/delete/${topicId}`, options);

// 群聊详情
export const ApiChatListDetail = (topicId: number, options?: _AxiosRequestConfig) => http.get<any>(`/im/topic/get/${topicId}`, options);

// 群聊用户
export const ApiChatListDetailUser = (topicId: number, options?: _AxiosRequestConfig) => http.get<any>(`/im/topic/user/${topicId}`, options);

// 群聊-发送消息
export const ApiChatSend = (data: any, options?: _AxiosRequestConfig) => http.post<any>(`/im/topic/message/send`, data, options);

// 群聊-消息已读
export const ApiChatRead = (topicId: number, options?: _AxiosRequestConfig) => http.put<any>(`/im/topic/message/read/${topicId}`, options);

// 群聊记录
export const ApiChatListRecord = (topicId: number, params: object, options?: _AxiosRequestConfig) => http.get<any>(`/im/topic/message/${topicId}/cursor-page`, params, options);

// 群聊-绑定登录人
export const ApiChatBind = (options?: _AxiosRequestConfig) => http.put<any>(`${baseUrl}/bind`, options);

// 群聊-绑定人
export const ApiChatUserBind = (data: any, options?: _AxiosRequestConfig) => http.post<any>(`${baseUrl}/manager`, data, options);

// 群聊-拉人
export const ApiChatUserAdd = (topicId: number, data: any, options?: _AxiosRequestConfig) => http.post<any>(`${baseUrl}/pull/${topicId}`, data, options);

// 群聊-踢人
export const ApiChatUserDelete = (topicId: number, params: object, options?: _AxiosRequestConfig) => http.delete<any>(`${baseUrl}/kick/${topicId}?userIds=${params}`, options);

// 应用-系统通知分页
export const ApiNewsList = (params: object, options?: _AxiosRequestConfig) => http.get<any>(`/im/system/message/cursor/page`, params, options);

// 系统消息已读
export const ApiNewsListRead = (options?: _AxiosRequestConfig) => http.put<any>(`/im/system/message/read`, options);

// 应用-系统通知消息
export const ApiNewDetail = (params: object, options?: _AxiosRequestConfig) => http.get<any>(`/im/system-message/newest`, params, options);

// 根据群聊ID去查询第一条@我的消息的定位ID
export const ApiGetFirstAiteId = (topicId: number, options?: _AxiosRequestConfig) => http.get<any>(`/im/topic/message/${topicId}/mentionedId`, options);

// 根据定位ID去查询消息
export const ApiGetFirstAiteIdList = (params: object, options?: _AxiosRequestConfig) => http.get<any>(`/im/topic/message/mentioned/jump`, params, options);
